#include<bits/stdc++.h>
#define fi first
#define se second
#define il inline
using namespace std;
#define ll long long
#define INT __int128
#define ld long double
#define pb emplace_back
#define lb(x) ((x)&-(x))
#define pii pair<int,int>
#define ull unsigned long long
#define MEM fabs(&__st-&__ed)/(1<<20)
#define TIME clock()*1.0/CLOCKS_PER_SEC
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define _rep(i,a,b) for(int i=(a),i##END=(b);i<=i##END;i++)
il int pc(int x){return __builtin_popcount(x);}
il int pc(ll x){return __builtin_popcountll(x);}
template<typename T> il void chkmin(T& x,T y){if(x>y)x=y;}
template<typename T> il void chkmax(T& x,T y){if(x<y)x=y;}
string bin(int x){return x<=1?(x?"1":"0"):bin(x>>1)+(x&1?"1":"0");}
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
#define rand(x,y) uniform_int_distribution<ll>(x,y)(rng)
void __file(string s){freopen((s+".in").c_str(),"r",stdin),freopen((s+".out").c_str(),"w",stdout);}
void __file(string s,int t){freopen((s+to_string(t)+".in").c_str(),"r",stdin),freopen((s+".out").c_str(),"w",stdout);}
#ifndef ONLINE_JUDGE
#define debug(x) (cerr<<#x<<": "<<x<<endl)
#undef DEBUG
#define DEBUG cerr<<"Passing ["<<__FUNCTION__<<"] in LINE "<<__LINE__<<endl
#else
#define debug(x) 0
#define DEBUG 0
#endif
bool __st;
const ll P=998244353;
ll qpow(ll x,ll y=P-2){ll z=1;while(y){if(y&1)z=z*x%P;x=x*x%P,y>>=1;}return z;}
#define int ll

const int N=1e6+5;
multiset<int> l0,r0,l1[N],r1[N];
// struct seg{
	int L[N<<2],R[N<<2],mx[N<<2],mn[N<<2],v[N<<2];
	#define ls (x<<1)
	#define rs (x<<1|1)
	void build(int x,int l,int r){
		L[x]=l,R[x]=r;
		mx[x]=-1e15,mn[x]=1e15,v[x]=1e15;
		if(l==r) return;
		int mid=(l+r)>>1;
		build(ls,l,mid),build(rs,mid+1,r);
	}
	void pu(int x){
		mx[x]=max(mx[ls],mx[rs]);
		mn[x]=min(mn[ls],mn[rs]);
		v[x]=min(min(v[ls],v[rs]),mn[rs]-mx[ls]);
	}
	void upd(int x,int d){
		if(L[x]==R[x]){
			if(r1[L[x]].size()) mn[x]=*r1[L[x]].begin(); 
			else mn[x]=1e15;
			if(l1[L[x]].size()) mx[x]=*--l1[L[x]].end();
			else mx[x]=-1e15;
			v[x]=mn[x]-mx[x];
			return;
		}
		if(d<=R[ls]) upd(ls,d);else upd(rs,d);
		pu(x);
	}
// }t;

int32_t main(){
	__file("stone");
	cin.tie(nullptr)->sync_with_stdio(false);
	build(1,1,1000000);
	int _;cin>>_;while(_--){
		char op;int l,r;
		cin>>op>>l>>r;
		if(op=='A'){
			l0.insert(l);r0.insert(r);l1[r].insert(l);r1[l].insert(r);
			upd(1,l),upd(1,r);
		}else{
			l0.erase(l0.find(l));r0.erase(r0.find(r));
			l1[r].erase(l1[r].find(l));r1[l].erase(r1[l].find(r));
			upd(1,l),upd(1,r);
		}
		if(*--l0.end()<*r0.begin()){
			int l=*--l0.end(),r=*r0.begin();
			cout<<*r1[l].begin()-*--l1[r].end()<<'\n';
		}else{
			cout<<v[1]<<'\n';
		}
	}
	return 0;
}